#include <Stats.h>
#include <time.h>

Stats::Stats() : r(0), w(0), t(time(NULL)) 
{   
}

Stats::~Stats()
{
}

qword Stats::getR()
{
   return r;
}

qword Stats::getW()
{
   return w;
}

qword Stats::getT()
{
   qword t2=time(NULL);
   return t2-t;
}

double Stats::getRS()
{
   qword t2=time(NULL);
   qword el=t2-t;
   if (el!=0)
      return (double)r/(double)el;
   else
      return 0;
}

double Stats::getWS()
{
   qword t2=time(NULL);
   qword el=t2-t;
   if (el!=0)
      return (double)w/(double)el;
   else
      return 0;
}

void Stats::addR(int n)
{
   r+=n;
}

void Stats::addW(int n)
{
   w+=n;
}

void Stats::reset()
{
   t=time(NULL);
   r=w=0;
}
